package com.zusmart.core.condition.extend;

import java.util.Map;

import com.zusmart.core.bean.BeanDefinition;
import com.zusmart.core.condition.Condition;
import com.zusmart.core.condition.ConditionContext;
import com.zusmart.core.config.ConfigSourceManager;
import com.zusmart.core.plugin.PluginManager;

public class ConditionalUnHasBeanRule extends ConditionalOnHasBeanRule implements Condition {

	@Override
	public boolean matches(ConditionContext conditionContext, Map<String, BeanDefinition> beanDefinitions, BeanDefinition targetBeanDefinition, PluginManager pluginManager, ConfigSourceManager configSourceManager) {
		ConditionalUnHasBean hasBean = (ConditionalUnHasBean) conditionContext.getExtendAnnotation();
		String value = hasBean.value();
		Class<?> clazz = hasBean.clazz().equals(Void.class) ? null : hasBean.clazz();
		return !this.doMatches(conditionContext, beanDefinitions, targetBeanDefinition, value, clazz);
	}

}